<template>
  <view class="content">
    <uni-card title="基础卡片" extra="额外信息">
      <text>这是一个基础卡片示例，此示例展示了一个标题加标题额外信息的标准卡片。</text>
    </uni-card>
    <image class="logo" src="/static/logo.png"></image>
    <image class="logo" src="@/static/icon_image.png"></image>
    <view class="text-area">
      <text class="title">{{ title }}</text>
      <text>{{ customMap.get(1) }}</text>
      <text>{{ list[1] }}</text>
    </view>
    <button @click="handleClick">点击</button>
    <button @click="handleScroll">滚动</button>
    <scroll-view
      class="scroll-view"
      :scroll-top="scrollTop"
      :scroll-y="true"
      :scroll-with-animation="true"
      :show-scrollbar="true"
    >
      <view v-for="item in 20" :key="item" class="scroll-view-item">Item {{ item }}</view>
    </scroll-view>
    <button @click="handleJump">跳转到列表</button>
  </view>
</template>

<script setup>
const title = ref('Hello')
const list = ref(['买赠', '满减', '折扣', '积分', '优惠券', '积分兑换', '积分抽奖', '积分抽奖'])
const scrollTop = ref(0)
const customMap = ref(
  new Map([
    [1, '买赠'],
    [2, '满减'],
    [3, '折扣'],
    [4, '积分'],
    [5, '优惠券'],
    [6, '积分兑换'],
    [7, '积分抽奖'],
    [8, '积分抽奖']
  ])
)

const handleClick = () => {
  list.value[1] = '更改满减'
}
watch(list, () => {
  console.log('触发', list)
})

const handleScroll = () => {
  scrollTop.value = 100
}
const handleJump = () => {
  uni.navigateTo({url: '/pages/list/list'})
}
</script>

<style>
.content {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.logo {
  height: 200rpx;
  width: 200rpx;
  margin-top: 200rpx;
  margin-left: auto;
  margin-right: auto;
  margin-bottom: 50rpx;
}

.text-area {
  display: flex;
  justify-content: center;
}

.title {
  font-size: 36rpx;
  color: #8f8f94;
}

.scroll-view {
  background-color: antiquewhite;
  height: 200rpx;
}
</style>
